package com.itita.ww2.data.shop;

import com.smartfoxserver.v2.entities.data.ISFSObject;

public class PaymentConfig {
	public static boolean isLoaded;

	private static ISFSObject goods; // 金币商店

	public static final void init(ISFSObject data) {
		goods = data.getSFSObject("payment");
		isLoaded = true;
	}

	public static final int getGoldCountBySKU(String sku) {
		return goods.getSFSObject(sku).getInt("amount");
	}

	public static final int getGoldFirstRewardBySKU(String sku) {
		return goods.getSFSObject(sku).getInt("first");
	}

	public static final int getPriceBySKU(String sku) {
		return goods.getSFSObject(sku).getInt("price");
	}

	public static final ISFSObject getPackItems(String sku) {
		return goods.getSFSObject(sku).getSFSObject("items");
	}

	public static final int getLimitCount(String sku) {
		int ref = Integer.MAX_VALUE;
		ISFSObject obj = goods.getSFSObject(sku);
		if (obj.containsKey("limit")) {
			ref = obj.getInt("limit");
		}
		return ref;
	}

	public static final Category getCategory(String sku) {
		return Category.values()[goods.getSFSObject(sku).getInt("category")];
	}

	public static final Type getType(String sku) {
		return Type.values()[goods.getSFSObject(sku).getInt("type")];
	}

	public static enum Category {
		UNKNOWN, // 0置位
		GOLD, // 1金条
		PACK, // 2礼包
	}

	public static enum Type {
		UNKNOWN, // 0置位
		INFINITY, // 1无限次购买
		CUSTOM, // 2限购自定义次数
	}
}
